home *** CD-ROM | disk | FTP | other *** search
- { ircle - Internet Relay Chat client }
- { File: IRCNComm }
- { Copyright ⌐ 1992 Olaf Titz (s_titz@iravcl.ira.uka.de) }
-
- { This program is free software; you can redistribute it and/or modify }
- { it under the terms of the GNU General Public License as published by }
- { the Free Software Foundation; either version 2 of the License, or }
- { (at your option) any later version. }
-
- { This program is distributed in the hope that it will be useful, }
- { but WITHOUT ANY WARRANTY; without even the implied warranty of }
- { MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the }
- { GNU General Public License for more details. }
-
- { You should have received a copy of the GNU General Public License }
- { along with this program; if not, write to the Free Software }
- { Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. }
-
- unit IRCNComm;
- { Handles numeric server messages. }
-
- interface
- uses
- TCPTypes, TCPStuff, TCPConnections, ApplBase, MsgWindows, {}
- IRCGlobals, IRCAux, IRCChannels, IRCCommands;
-
- function NumericComm (comm: integer; var from, target, rest: string): boolean;
- { Handles numeric message comm with arguments from, target, rest }
-
- implementation
-
- function NumericComm (comm: integer; var from, target, rest: string): boolean;
- var
- s: string[200];
- s1, s2, s3, s4: string[80];
- i: integer;
- begin
- NumericComm := true;
- { Numerics and their meanings taken mostly from IRCII. }
- { Where there are different formats for 2.6/2.7, this will work with 2.7 as tested. }
- { Here messages are sorted by type }
- case comm of
-
- { generic line }
- 364, { new LINKS reply }
- 391, { TIME reply }
- 372: { new MOTD reply }
- if not flushing then
- LineMsg(rest);
-
- { generic line with from field }
- 200..209, 213..218: { TRACE/STATS info }
- if not flushing then begin
- s := concat(from, ': ', rest);
- LineMsg(s)
- end;
-
- { generic error message }
- 401..414, { no such nick/server/channel; cannot send }
- 421, { unknown command }
- 431, 432, { bogus nick }
- 461, { need passwd }
- 472, { unknown mode }
- 481, 482: { no privileges }
- begin
- s := concat('*** ', rest);
- LineMsg(s);
- end;
-
- { generic error with from field }
- 471, 473, 474, { Cannot join }
- 331: { Topic bogosity }
- begin
- s := concat('*** (', from, ') ', rest);
- LineMsg(s)
- end;
-
- {╩Status information }
- 301: { user is away }
- begin
- NextArg(rest, s1);
- s := concat(s1, ' is away (', rest, ')');
- Message(s)
- end;
- 332: { Topic }
- begin
- s := concat('Topic is: ', rest);
- Message(s)
- end;
-
- { Verbose command replies }
- 211: { STATS L reply }
- begin
- NextArg(rest, s1);
- s := concat('**', s1, '**');
- LineMsg(s);
- s := '';
- for i := 1 to 5 do begin
- NextArg(rest, s1);
- s := stringof(s, s1 : 12);
- end;
- s := concat(s, ' ', rest);
- LineMsg(s)
- end;
- 352: { new WHO reply }
- if not flushing then begin
- NextArg(rest, s1);
- if s1 <> 'Channel' then begin
- NextArg(rest, s2);
- NextArg(rest, s3);
- s2 := concat(s2, '@', s3);
- NextArg(rest, s3);
- NextArg(rest, s3);
- NextArg(rest, s4);
- s := StringOf(s1 : 10, ' ', s3 : 9, s4 : 4, ' ', s2, ' (', rest, ')');
- ChannelMsg(s1, s)
- end;
- end;
- 353: { new NAMES reply }
- if not flushing then begin
- s := copy(rest, 3, 255);
- i := pos(' ', s);
- s1 := copy(s, 1, i - 1);
- ChannelMsg(s1, s)
- end;
- 311: { whois name info }
- begin
- NextArg(rest, s1);
- NextArg(rest, s2);
- NextArg(rest, s3);
- s := concat(s1, ' is ', s2, '@', s3, ' (', copy(rest, 4, 255), ')');
- Message(s)
- end;
- 314: { whowas name info }
- begin
- NextArg(rest, s1);
- NextArg(rest, s2);
- NextArg(rest, s3);
- s := concat(s1, ' was ', s2, '@', s3, ' (', copy(rest, 4, 255), ')');
- Message(s)
- end;
- 313: { whois operator }
- begin
- NextArg(rest, s1);
- s := concat(s1, ' ', rest);
- Message(s)
- end;
- 319: { whois channels }
- begin
- NextArg(rest, s1);
- s := concat(s1, ' is on channels ', rest);
- Message(s)
- end;
- 312: { whois host/server }
- begin
- NextArg(rest, s1);
- s := concat('On IRC via server ', rest);
- Message(s)
- end;
- 317: { whois idle }
- begin
- NextArg(rest, s1);
- NextArg(rest, s2);
- s := concat('idle since ', s2);
- Message(s)
- end;
- 321, 322: { LIST header/entry }
- if not flushing then begin
- NextArg(rest, s1);
- NextArg(rest, s2);
- s := StringOf(copy(s1, 1, 12) : 12, s2 : 4, ' ', copy(rest, 1, 60));
- LineMsg(s);
- lastWindow := nil; { save from net.terrorists with awfully long topics }
- end;
- 341: { invite confirmation }
- begin
- NextArg(rest, s1);
- s := concat('Inviting ', s1, ' to channel ', rest);
- lastInvite := rest;
- ChannelMsg(rest, s)
- end;
- 351: { Server version }
- begin
- NextArg(rest, s1);
- s := concat(from, ' runs version ', s1);
- Message(s)
- end;
-
- { End of list }
- 366, 323, 315, 318, 365, 219, 368: { End of list }
- begin
- flushing := false;
- UpdateStatusLine
- end;
-
- { Various errors }
- 433: { Nick in use }
- begin
- NextArg(rest, s1);
- s := concat('*** Nickname ', s1, ' is in use. You have to choose another.');
- LineMsg(s);
- end;
- 463..466: { server refuses connection }
- begin
- s := concat('*** ', from, ' refuses connection: ', rest);
- LineMsg(s)
- end;
-
- { messages that generate a response }
- 451: { not registered }
- begin
- s := concat('*** Registration failed, trying again...');
- LineMsg(s);
- RegUser
- end;
-
- otherwise
- NumericComm := false
- end;
- end;
-
- end.